<?php
namespace OpenApi\Controller;
use Think\Controller;
class IndexController extends Controller{
	public function _initialize()
	{
		$g=session('company');
		C('erp_dbname',$g['db']);
		$db_name=$g['db'];
		//数据库连接基础配置-begin
		C('db_config.DB_TYPE',C('DB_TYPE'));
		C('db_config.DB_HOST',C('DB_HOST'));
		C('db_config.DB_USER',C('DB_USER'));
		C('db_config.DB_PWD',C('DB_PWD'));
		C('db_config.DB_PORT',C('DB_PORT'));
		C('db_config.DB_CHARSET',C('DB_CHARSET'));
		C('db_config.DB_NAME',C('erp_dbname'));
		//数据库连接基础配置-end
	}

	public function Index()
	{
		$db_name = session('company.db');
		$book = M('Book',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		$user_id=session('company.id');
		$warehouse=M('Warehouse');
		$uw=M('UserWarehouse');
		$uw_info=$uw->where(array('user_id'=>$user_id))->find();
		$warehouse_idlist=array_unique(explode(',',$uw_info['warehouse_group_id']));
		$manua_id_list=$book->select();
		foreach($manua_id_list as $ks=>$vs){
			$arr_list[]=$vs['book_no'];
		}

		$warehouse_list=$warehouse->where(array('id'=>array('in',$warehouse_idlist)))->select();
		$manua_idlist=implode(',',$arr_list);

		$data['warehouse_list'] = $warehouse_list;
		$data['manua_id'] = $manua_idlist;

		alert_json_new(1,'',$data);
	}
}